package com.xinqi.modules.chat.chat.friend.controller.web;

import com.xinqi.common.base.response.R;
import com.xinqi.common.satoken.utils.LoginHelper;
import com.xinqi.modules.chat.chat.friend.dto.req.ChatFriendApplyMessageCreateDTO;
import com.xinqi.modules.chat.chat.friend.dto.rsp.ChatFriendApplyMessageResultDTO;
import com.xinqi.modules.chat.chat.friend.service.ChatFriendApplyMessageService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * WEB -- 申请加好友消息内容
 *
 * @version V1.0
 * @Title:
 * @ClassName: com.xinqi.modules.chat.chat.friend.controller.web.ChatFriendApplyMessageWebController.java
 * @Description:
 * @Copyright 星齐科技（云南）有限公司 - Powered By 技术部
 * @author: yyzhen
 * @date: 2023/5/19 10:05
 */
@Validated
@RestController
@RequestMapping("/web/friend-apply-message")
@RequiredArgsConstructor
public class ChatFriendApplyMessageWebController {
    private final ChatFriendApplyMessageService chatFriendApplyMessageService;

    @Operation(summary = "好友申请回复")
    @PostMapping
    public R<Long> insert(@Validated @RequestBody ChatFriendApplyMessageCreateDTO dto) {
        dto.setOperationUserId(LoginHelper.getUserId());
        return R.data(chatFriendApplyMessageService.insert(dto));
    }

    @Operation(summary = "好友申请会话-列表")
    @GetMapping("/{applyId}/apply-msg-list")
    public R<List<ChatFriendApplyMessageResultDTO>> getFriendApplyMessage(@NotNull(message = "{chat.friend.apply.id.not.blank}") @PathVariable("applyId") Long applyId) {
        return R.data(chatFriendApplyMessageService.findByApplyId(applyId));
    }

}
